﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Kkc.Common;

namespace Kkc.Application.Controllers
{
    public class IocControllerFactory: System.Web.Mvc.DefaultControllerFactory
    {
        public override System.Web.Mvc.IController CreateController(System.Web.Routing.RequestContext requestContext, string controllerName)
        {
            var controllerType = base.GetControllerType(controllerName);

            return IocContainer.Current.Resolve(controllerType) as IController;
        }

        public override void ReleaseController(System.Web.Mvc.IController controller)
        {
            IocContainer.Current.Teardown(controller);
        }
    }
}